package day01_homework;

import java.util.Random;
import java.util.Scanner;

public class Test07 {
    public static void main(String[] args) {
        //48-57 97-122 65-90
        Random random = new Random();
        char[] chars = new char[5];
        String str = "";
        for (int i = 0; i < 5; i++) {
            int num = random.nextInt(3);
            if (num == 0) {
                chars[i] = (char) (random.nextInt(26) + 65);
            } else if (num == 1) {
                chars[i] = (char) (random.nextInt(26) + 97);
            } else {
                chars[i] = (char) (random.nextInt(10) + 48);
            }
            System.out.println(chars[i]);
            str += String.valueOf(chars[i]);
        }
        System.out.println(str);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入验证码：");
        String input = scanner.next();
        boolean check = input.equalsIgnoreCase(str);
        if (check) {
            System.out.println("验证码正确");
        } else {
            System.out.println("验证码错误");
        }

    }
}
